/*
https://codeforces.com/contest/1513/submission/292192066
*/
#include<iostream>
#include<cstring>
#include<stdio.h>
using namespace std;

const int n = 200005;
long long f[n][10];
int mod = 1e9 + 7;
int main()
{
    int t;
    scanf("%d", &t);
    for (int i = 0; i < 10; ++i) {
        f[0][i] = 1;
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= 9; ++j) {
            f[i][j - 1] = f[i - 1][j];
        }
        f[i][9] = (f[i - 1][1] + f[i - 1][0]) % mod;
    }
    while (t--) {
        char s[20];
        int m, ans = 0;
        scanf("%s %d", &s, &m);
        int len = strlen(s);
        for (int i = 0; i < len; ++i) {
            int sz=s[i] - '0';
            ans += f[m][sz];
            ans %= mod;
        }
        printf("%d\n", ans);
    }
    return 0;
}